<?php

namespace app\model;

use think\Model;

class MemberAccount extends Model
{

	protected $connection = 'mysql';

	protected $pk = 'id';

	protected $name = 'member_account';


	public static function getpoints($mid, $atid)
	{
		$data = self::where(['mid' => $mid, 'atid' => $atid])->find()?->toArray();
		if (empty($data)) {
			self::create(['mid' => $mid, 'atid' => $atid, 'points' => 0]);
			$data = self::where(['mid' => $mid, 'atid' => $atid])->find()?->toArray();
		}
		return $data['points'];
	}
}
